﻿using Reckoning;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace TestReckoning
{
    
    
    /// <summary>
    ///This is a test class for WordCountInfoTest and is intended
    ///to contain all WordCountInfoTest Unit Tests
    ///</summary>
    [TestClass()]
    public class WordCountInfoTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        /// Construct an empty object
        /// </summary>
        /// <returns>The object</returns>
        WordCountInfo MakeObject()
        {
            string word = string.Empty;
            Dictionary<string, uint> variants = null;
            uint count = 0;
            double pot = 0F;
            double refPot = 0F;
            WordCountInfo target = new WordCountInfo(word, variants, count, pot, refPot);

            return target;
        }

        /// <summary>
        ///A test for WordCountInfo Constructor
        ///</summary>
        [TestMethod()]
        public void WordCountInfoConstructorTest()
        {
            WordCountInfo target = MakeObject();
            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for Count
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Reckoning.exe")]
        public void CountTest()
        {
            PrivateObject param0 = new PrivateObject(MakeObject());
            WordCountInfo_Accessor target = new WordCountInfo_Accessor(param0); 
            uint expected = 11;
            uint actual;
            target.Count = expected;
            actual = target.Count;
            Assert.AreEqual(expected, actual);            
        }

        /// <summary>
        ///A test for PercentageOfTotal
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Reckoning.exe")]
        public void PercentageOfTotalTest()
        {
            PrivateObject param0 = new PrivateObject(MakeObject());
            WordCountInfo_Accessor target = new WordCountInfo_Accessor(param0);
            double expected = 20F; 
            double actual;
            target.PercentageOfTotal = expected;
            actual = target.PercentageOfTotal;
            Assert.AreEqual(expected, actual);            
        }

        /// <summary>
        ///A test for Rank
        ///</summary>
        [TestMethod()]
        public void RankTest()
        {            
            WordCountInfo target = MakeObject();
            int expected = 22; 
            int actual;
            target.Rank = expected;
            actual = target.Rank;
            Assert.AreEqual(expected, actual);            
        }

        /// <summary>
        ///A test for Ratio
        ///</summary>
        [TestMethod()]
        public void RatioTest0()
        {
            string word = string.Empty;
            Dictionary<string, uint> variants = null;
            uint count = 0;
            double pot = 10F;
            double refPot = 0F;
            WordCountInfo target = new WordCountInfo(word, variants, count, pot, refPot);
            double expected = 0F;
            double actual = target.Ratio;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Ratio
        ///</summary>
        [TestMethod()]
        public void RatioTest1()
        {
            string word = string.Empty; 
            Dictionary<string, uint> variants = null;
            uint count = 0; 
            double pot = 10F; 
            double refPot = 20F; 
            WordCountInfo target = new WordCountInfo(word, variants, count, pot, refPot);
            double expected = pot / refPot;
            double actual = target.Ratio;
            Assert.AreEqual(expected, actual);            
        }

        /// <summary>
        ///A test for ReferencePercentageOfTotal
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Reckoning.exe")]
        public void ReferencePercentageOfTotalTest()
        {
            PrivateObject param0 = new PrivateObject(MakeObject());
            WordCountInfo_Accessor target = new WordCountInfo_Accessor(param0);
            double expected = 39F;             
            target.ReferencePercentageOfTotal = expected;
            double actual = target.ReferencePercentageOfTotal;
            Assert.AreEqual(expected, actual);            
        }

        /// <summary>
        ///A test for Variants
        ///</summary>
        [TestMethod()]
        public void VariantsTest()
        {
            string word = "whatever";
            Dictionary<string, uint> variants = new Dictionary<string,uint>();
            variants.Add("a", 1);
            variants.Add("b", 2);
            string expected = "a (1), b (2)";
            uint count = 3;
            double pot = 10F;
            double refPot = 0F;
            WordCountInfo target = new WordCountInfo(word, variants, count, pot, refPot); 
            string actual = target.Variants;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Word
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Reckoning.exe")]
        public void WordTest()
        {
            PrivateObject param0 = new PrivateObject(MakeObject());
            WordCountInfo_Accessor target = new WordCountInfo_Accessor(param0); 
            string expected = "blah";            
            target.Word = expected;
            string actual = target.Word;
            Assert.AreEqual(expected, actual);            
        }
    }
}
